﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace HY.BLL.oa
{
 public    class addbook
    {
     public Model.oa.addbook sk = new Model.oa.addbook();

     public static DataTable get_list(string us)
     {
         string sqltxt = "select * from addbook where bnm='"+us+"'  ";

         sqltxt = sqltxt + " order by sid desc ";
         DataTable dt = DAL.DbHelperSQL.SqlDataAdapter(sqltxt);
         return dt;
     }

     

     public static DataTable get_list(string us,string whe)
     {
         string sqltxt = "select * from addbook where  bnm='" + us + "'   ";
         if (whe != "") sqltxt =sqltxt+ " and " + whe;

          sqltxt = sqltxt + " order by sid desc ";
         DataTable dt = DAL.DbHelperSQL.SqlDataAdapter(sqltxt);
         return dt;
     }



     public static int ins_task(Model.oa.addbook s)
     {
         string sqltxt = "insert into addbook values(N'" + s.bnm + "',N'" + 
                                                          s.bname + "',N'" +
                                                          s.sex + "',N'" +
                                                          s.bsday + "',N'" +
                                                          s.address + "',N'" +
                                                          s.tel + "',N'" +
                                                          s.phone + "',N'" +
                                                          s.fax + "',N'" +
                                                          s.mail + "',N'" +
                                                          s.qq + "',N'" +
                                                          s.msn + "',N'" +
                                                          s.remarks + "',N'" +
                                                          s.stel +"')  ";

         return DAL.DbHelperSQL.ExecuteNonQuery(sqltxt);

     }


     public static int ups_task(Model.oa.addbook s)
     {
         string sqltxt = "update addbook set bnm=N'" + s.bnm + "',bname=N'" +
                                                       s.bname + "',sex=N'" +
                                                       s.sex + "',bsday=N'" +
                                                       s.bsday + "',address=N'" +
                                                       s.address + "',tel=N'" +
                                                       s.tel + "',phone=N'" +
                                                       s.phone + "',fax=N'" +
                                                       s.fax + "',mail=N'" +
                                                       s.mail + "',qq=N'" +
                                                       s.qq + "',stel=N'" +
                                                       s.stel + "',msn=N'" +
                                                       s.msn + "',remarks=N'" +
                                                       s.remarks + "' where sid="+s.sid;
         return DAL.DbHelperSQL.ExecuteNonQuery(sqltxt);

     }

     /// <summary>
     /// 删除一条数据
     /// </summary>
     public static int DeleteList(string sidlist)
     {
         string sqltxt = "delete addbook where sid in(" + sidlist + ") ";
         return DAL.DbHelperSQL.ExecuteNonQuery(sqltxt);
     }

    }
}
